﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Script.Serialization;
using Utilities;

namespace Models.WebSite_HaiSheng
{
    public class Article : EntityBase
    {
        [Display(Name="标题"), Required()]
        public string Title { get; set; }

        [Display(Name = "副标题")]
        public string SubTitle { get; set; }

        [Display(Name = "内容"), Required(ErrorMessage = "请填的内容")]
        public string Content { get; set; }

        [Display(Name = "发布人"), Required()]
        public string Pubulisher { get; set; }

        [Display(Name = "发布时间"), Required()]
        public DateTime PubulishTime { get; set; }

        public List<Image> GetImages()
        {
              var imgs = from ir in CH.DB.ImageRelateTos
                         from image in CH.DB.Images
                         where image.ID == ir.ImageId && ir.RelateId == this.ID && ir.RelateType=="Article"
                         select image;

              var list = imgs.ToList();
   
            return list;
        }

        [Display(Name = "文章的类型"), Required(ErrorMessage = "请选择文章的类型")]
        public string  ArticleType { get; set; }
    }
}